<?php
// -----------------------------------------------------------------------------
// include
// -----------------------------------------------------------------------------

include "../config/config.php";
include "../auth.php";
include "../DBManager.php";

// -----------------------------------------------------------------------------

/* 判断相应的文件夹是否存在 */

$path = explode("/", $dbPath);
$path = "../" . $path[0];

if (!is_dir($path)) {
    mkdir($path);
}

// -----------------------------------------------------------------------------

/* 重建数据库 */

if ($dbReCreatable == "true") {

    $dbPath = "../" . $dbPath; // 不加这行语句的话会报错，提示找不到对应路径
    $db = new DBManager("sqlite:" . $dbPath);
    $db->recreateTables();
    echo <<<BBB
    数据库重建成功！
    BBB;

} else {

    echo '数据库重建失败！请先在配置文件中修改变量 $dbReCreatable 的值，允许数据库被重建。';

}

// -----------------------------------------------------------------------------
